exports.sqlUserTable = [
  /**
   * 
   */
  {
    sql: `
    CREATE TABLE IF NOT EXISTS users (
      id INT AUTO_INCREMENT PRIMARY KEY,
      username VARCHAR(50),
      password VARCHAR(18),
      phone VARCHAR(11),
      code VARCHAR(6),
      token VARCHAR(255),
      type VARCHAR(30) NOT NULL DEFAULT 'username' CHECK (type IN ('username', 'phone')),
      login_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      uid VARCHAR(255),
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )
  `,
    name: '用户users'
  },
  {
    sql: `
    CREATE TABLE IF NOT EXISTS orders (
      id INT AUTO_INCREMENT PRIMARY KEY,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      user_id INT NOT NULL,
      FOREIGN KEY (user_id) REFERENCES users(uid),
      goods_id INT NOT NULL,
      FOREIGN KEY (goods_id) REFERENCES goods(id),
      order_status INT DEFAULT 0,
      payment_method INT DEFAULT 0,
      payment_status INT DEFAULT 0,
      shipping_method VARCHAR(255),
      price DECIMAL(10, 2) NOT NULL,
      quantity INT NOT NULL,
      total DECIMAL(10, 2) GENERATED ALWAYS AS (quantity * price) STORED,
      address VARCHAR(255) NOT NULL,
      is_delivery INT DEFAULT 0,
      delivery_time DATETIME
    )
  `,
    name: '用户orders'
  },
  {
    sql: `
    CREATE TABLE IF NOT EXISTS carts (
      id INT AUTO_INCREMENT PRIMARY KEY,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      user_id INT NOT NULL,
      FOREIGN KEY (user_id) REFERENCES users(uid),
      goods_id INT NOT NULL,
      FOREIGN KEY (goods_id) REFERENCES goods(id),
      quantity INT NOT NULL DEFAULT 1,
      price DECIMAL(10, 2) NOT NULL,
      total DECIMAL(10, 2) GENERATED ALWAYS AS (quantity * price) STORED
    )
  `,
    name: '用户carts'
  },
]